package com.homework.HomeAcount.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.homework.HomeAcount.dao.RoleDao;
import com.homework.HomeAcount.entity.Role;
import com.homework.HomeAcount.service.RoleService;

@Service("roleService")
public class RoleServiceImpl implements RoleService {
	
	@Autowired
	private RoleDao roleDao;

	@Override
	public List<Role> getRolesByUserId(String userId) {
		return roleDao.getRolesByUserId(userId);
	}

	@Override
	public List<Role> getAllRoles() {
		return roleDao.getAllRoles();
	}

	@Override
	public void roleAllocated(String userId, List<Map<String, Object>> list) throws Exception {
		roleDao.deleteRoleByUserId(userId);
		roleDao.addUserRoles(list);
		
	}

}
